// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import { companyType, workType } from "../../../../script/game/gameType";
import { ListItem } from "../../../../script/util/ListView/ListItem";
import { ccs } from "../../../../script/util/services";

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends ListItem<workType> {
    
    @property(cc.Label)
    title: cc.Label = null;
    
    @property(cc.Node)
    img: cc.Node = null;

    initItem(data: workType, index: number) {
        this.title.string = data.name;
        ccs.spriteExd.setSprite(this.img, ccs.resMgr.getCompanyIcon(data.id));
    }
    onItemclick(data: workType) {
        ccs.mainEmitter.emit("upWorkInfo", data.id);
    }
}
